{% extends '../../../layout/admin-base.html' %}
<script src="{{ assets_path("js/base.js")}}"></script>
{% block page %}
<h3 class="page-title">
    外送记录 <small>列表</small>
</h3>
<ul class="breadcrumb">
    <li>
        <i class="icon-home"></i>
        <a href="index.html">基本信息管理</a> 
        <i class="icon-angle-right"></i>
    </li>
    <li>
        <a href="{{url('admin/foot/outlog')}}">外送记录管理</a>
        <i class="icon-angle-right"></i>
    </li>
    <li><span>列表</span></li>
</ul>
{% end%}
{% block content %}

<div class="row-fluid">
    <div class="span12">
        <div class="portlet box red">
            <div class="portlet-title">
                <div class="caption"><i class="icon-search"></i>搜索条件</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                </div>
            </div>
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <form action="{{url('admin/food/outlogsearch')}}" class="horizontal-form" method="get">
                    <div class="row-fluid">
                    <!--
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label" for="studentName">下单时间</label>
                                <div class="controls">
                                    <input type="text" id="studentName" class="m-wrap span12" placeholder="">
                                </div>
                            </div>
                        </div>
                        -->
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label" for="no">下单人</label>
                                <div class="controls">
                                    <input type="text" id="no" class="m-wrap span12" placeholder="" name="Fname">
                                </div>
                            </div>
                        </div>
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label" for="dormNo">手机号</label>
                                <div class="controls">
                                    <input type="text" id="dormNo" class="m-wrap span12" placeholder="" name="Ftel">
                                </div>
                            </div>
                        </div>
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label">是否完成</label>
                                <div class="controls">
                                    <select class="m-wrap span12" name="Fstatus">
                                        <option value="0">未发出</option>
                                        <option value="1">派送中</option>
                                        <option value="2">已完成</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--/row-->
                    <div class="form-actions">
                        <button type="submit" class="btn blue"><i class="icon-search"></i>搜索</button>
                        <button type="reset" class="btn">清空</button>
                    </div>
                </form>
                <!-- END FORM--> 
            </div>
        </div>
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box light-grey">
            <div class="portlet-title">
                <div class="caption"><i class="icon-list"></i>宿舍楼列表</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="#portlet-config" data-toggle="modal" class="config"></a>
                    <a href="javascript:;" class="reload"></a>
                    <!-- <a href="javascript:;" class="remove"></a> -->
                </div>
            </div>
            <div class="portlet-body">
                <div class="clearfix">
                    <div class="btn-group">
                        <a id="status1" class="btn green">
                        批量派送<i class="icon-plus"></i>
                        </a>
                        <a id="status2" class="btn blue">
                        批量完成<i class="icon-ok"></i>
                        </a>
                    </div>
                    <div class="btn-group pull-right">
                        <button class="btn dropdown-toggle" data-toggle="dropdown">工具<i class="icon-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="#">打印</a></li>
                            <li><a href="#">另存为PDF</a></li>
                            <li><a href="#">另存为Excel</a></li>
                        </ul>
                    </div>
                </div>
                <table class="table table-striped table-bordered table-hover" id="sample_1">
                    <thead>
                        <tr>
                            <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" id="all"/></th>
                            <th>下单时间</th>
                            <th class="hidden-300">下单人</th>
                            <th class="hidden-240">手机号</th>
                            <th class="hidden-300">点餐内容</th>
                            <th class="hidden-300">总价</th>
                            <th class="hidden-480">支付方式</th>
                            <th class="hidden-480">地址</th>
                            <th class="hidden-200">状态</th>
                            <th class="hidden-200">备注</th>
                            <th ></th>
                        </tr>
                    </thead>
                    <tbody id="list">
                        {% for row in restlist %}
                        <tr class="odd gradeX">  
                            <td><input type="checkbox" class="checkboxes" value="{{row['Fid'] }}" name="select" /></td>
                            <td>{{stamp_2_time(row['Fcreate_time']) }}</td>
                            <td>{{row['Fname']}}</td>
                            <td>{{row['Ftel']}}</td>
                            <td>{{row['Ftext']}}</td>
                            <td>￥{{row['Fprice']}}</td>
                            <td>{%if row['Fpay']=='1'%}
                            现金
                            {%elif row['Fpay']=='2'%}
                            POS机
                            {% elif row['Fpay']=='3' %}
                            签单
                            {%else%}
                            支付宝
                            {%end%}
                            </td>
                            <td>{{row['Faddress']}}</td>
                            <td class="center hidden-100">
                            {%if row['Fstatus']=='0'%}
                            <span class="btn mini black">
                             未发出
                            </span>
                             {%elif row['Fstatus']=='1'%}
                             <span class="btn mini green">
                             派送中
                             </span>
                             {%else %}
                             <span class="btn mini red">
                             已完成
                             </span>
                             {%end%}
                            </td>
                            <td class="hidden-100">{{row['Finfo']}}</td>
                            <td ><a class="btn mini purple" href="{{url('admin/food/outlog/status?Fid='+row['Fid']+'&Fstatus=1')}}"><i class="icon-edit"></i>派送中</a>
                                <a class="btn mini blue" href="{{url('admin/food/outlog/status?Fid='+row['Fid']+'&Fstatus=2')}}"><i class="icon-ok"></i>完成</a>
                            </td>
                        </tr>
                        {% end %}

                    </tbody>
                </table>
                {% module Paginate(page_info['total'], page_info['page']) %}
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
</div>

<script type="text/javascript">
window.onload = function(){
    
    function set_status(t){
        data = ''
        for(var i = 0;i < $("input[name='select']").length;i++){
            if($("input[name='select']")[i].checked){
                data += $("input[name='select']")[i].value + ','
            }
        }

        if(data != ''){
            $.post("{{ reverse_url('food.set_istatus', page_info['page'], '') }}" + t,{data:data},function(result){

                window.location.href = '{{ reverse_url("food.outlog") }}page={{ page_info["page"] }}'
            });
        }
    }

    $('#status1').click(function(){
        set_status('1')
        
    })
    $('#status2').click(function(){
        set_status('2')
    })
}
</script>
{% end%}